home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1993 July / InfoMagic USENET CD-ROM July 1993.ISO / sources / unix / volume10 / logo / patch01 < prev    next >
Encoding:
Internet Message Format  |  1987-07-06  |  24.9 KB

  1. Path: uunet!rs
  2. From: rs@uunet.UU.NET (Rich Salz)
  3. Newsgroups: comp.sources.unix
  4. Subject: v10i043:  Patches to Logo for Suntools
  5. Message-ID: <583@uunet.UU.NET>
  6. Date: 7 Jul 87 23:23:24 GMT
  7. Organization: UUNET Communications Services, Arlington, VA
  8. Lines: 915
  9. Approved: rs@uunet.uu.net
  10.  
  11. Submitted by: cochon@Sun.COM (Philippe Lacroute)
  12. Mod.sources: Volume 10, Number 43
  13. Archive-name: logo/Patch01
  14.  
  15. [  The Sun version in the original posting needed a graphics library
  16.    developed at Lucasfilm; here's something more useful. --r$  ]
  17.  
  18. This file contains instructions for creating a version of Logo to run
  19. under Suntools.  You need four new files which follow below:  sun.i,
  20. logo.c, logo.icon and Makefile.  The following changes must be made to
  21. the logo source as well.  I believe the line numbers refer to version 4
  22. source but hopefully with the context given for each change it won't
  23. matter.  "Make" will produce two binaries: logo and logotool.  When
  24. running logo under suntools use logotool instead of logo (logotool
  25. actually creates a window and then forks logo to run in it; logotool
  26. then handles repaint requests for the tool).
  27.  
  28. Note: the routines in sun.i currently only support monochrome graphics
  29. (although it would not be difficult to add color).  I made these
  30. changes several years ago and I haven't devoted any time to the code
  31. since then, but they still compile under any version of SunOS from 1.0
  32. on (that's when SunWindows was introduced).
  33.  
  34. #! /bin/sh
  35. # This is a shell archive.  Remove anything before this line, then unpack
  36. # it by saving it into a file and typing "sh file".  To overwrite existing
  37. # files, type "sh file -c".  You can also feed this as standard input via
  38. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  39. # will see the following message at the end:
  40. #        "End of shell archive."
  41. # Contents:  logo.mods sun.i logo.c logo.icon Make.Sun
  42. # Wrapped by rsalz@uunet.uu.net on Tue Jul  7 12:27:11 1987
  43. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  44. if test -f logo.mods -a "${1}" != "-c" ; then 
  45.   echo shar: Will not over-write existing file \"logo.mods\"
  46. else
  47. echo shar: Extracting \"logo.mods\" \(2328 characters\)
  48. sed "s/^X//" >logo.mods <<'END_OF_logo.mods'
  49. XThe first two changes add the commands fill and textsize.  Fill fills in the
  50. Xregion around the current position of the turtle using the current pen color.
  51. XThe boundary of the fill can be an arbitrary shape (for instance:
  52. X"repeat 4 [fd 100 rt 90] rt 45 fd 10 fill" produces a black square).  If the
  53. Xboundary has "holes", the whole screen may get filled.  Textsize takes one
  54. Xargument which is the number of lines you want the text window to be in split
  55. Xmode.
  56. X
  57. Xlogo.y:98 insert 3 lines
  58. X        #ifdef SETCURSOR
  59. X        struct object *clrtxt(), *setcur();
  60. X        #endif
  61. X    ->  #ifdef SUN
  62. X    ->  struct object *fill_region(), *text_size();
  63. X    ->  #endif
  64. X
  65. X        struct lexstruct keywords[] =
  66. X        {
  67. X
  68. X
  69. Xlogo.y:203 insert 4 lines
  70. X
  71. X            "scrunch",NOOP,scrunch,NULL,
  72. X            "setscrunch",ONECOM,setscrunch,"setscrun",
  73. X    ->  #ifdef SUN
  74. X    ->        "fill",NOCOM,fill_region,NULL,
  75. X    ->        "textsize",ONECOM,text_size,"ts",
  76. X    ->  #endif
  77. X        #endif
  78. X            "toplevel",NOCOM,ltopl,NULL,
  79. X            "fprint",ONECOM,cmfprint,"fp",
  80. X
  81. X
  82. Xlogoparse.c:142 add 3 lines
  83. X
  84. X            else if (ibufptr==NULL) {
  85. X            rebuff:
  86. X    ->  #ifdef SUN
  87. X    ->            sigwinch_on();
  88. X    ->  #endif
  89. X                if ((c=read(0,ibuf,IBUFSIZ))==IBUFSIZ)
  90. X                    if (ibuf[IBUFSIZ-1]!='\n') {
  91. X
  92. X
  93. Xlogoparse.c:152 add 3 lines
  94. X
  95. X                        puts("Your line is too long.");
  96. X                        errhand();
  97. X                    }
  98. X    ->  #ifdef SUN
  99. X    ->            sigwinch_off();
  100. X    ->  #endif
  101. X                if (c<0) {
  102. X                    /* Error return from read.  Probably signal.*/
  103. X                    return ('\n');
  104. X
  105. Xprocedit.c:107 add 3 lines
  106. X
  107. X                static char editname[20] = "";
  108. X                static char *editor;
  109. X    ->  #ifdef SUN
  110. X    ->        int sig_mask;
  111. X    ->  #endif
  112. X
  113. X            if (editname[0] == '\0') {
  114. X                editor = getenv("EDITOR");
  115. X
  116. X
  117. Xprocedit.c:107 add 3 lines
  118. X
  119. X            fflush(stdout);
  120. X            signal(SIGINT,SIG_IGN);
  121. X            signal(SIGQUIT,SIG_IGN);
  122. X    ->  #ifdef SUN
  123. X    ->        sig_mask = sigblock(1 << (SIGWINCH-1));
  124. X    ->  #endif
  125. X            switch (pid=fork()) {
  126. X                case -1:
  127. X                    printf("\nCan't fork to editor.\n");
  128. X
  129. Xprocedit.c:120 add 3 lines
  130. X                default:
  131. X                    while (wait(&status) != pid) ;
  132. X    ->  #ifdef SUN
  133. X    ->                sigsetmask(sig_mask);
  134. X    ->  #endif
  135. X            }
  136. X            if (status&0177400) {
  137. X
  138. X
  139. Xturtle.c:384 add 3 lines
  140. X
  141. X                errhand();
  142. X            }
  143. X            if (turtdes == 0) dpyinit();    /* free turtle "display */
  144. X    ->  #ifdef SUN
  145. X    ->        checkwindow();
  146. X    ->   #endif
  147. X        }
  148. X
  149. X        NUMBER posangle(angle)
  150. X
  151. END_OF_logo.mods
  152. if test 2328 -ne `wc -c <logo.mods`; then
  153.     echo shar: \"logo.mods\" unpacked with wrong size!
  154. fi
  155. # end of overwriting check
  156. fi
  157. if test -f sun.i -a "${1}" != "-c" ; then 
  158.   echo shar: Will not over-write existing file \"sun.i\"
  159. else
  160. echo shar: Extracting \"sun.i\" \(11542 characters\)
  161. sed "s/^X//" >sun.i <<'END_OF_sun.i'
  162. X
  163. X/* Include file for turtle.c for Sun Microsystems workstation */
  164. X
  165. X/* modified for use with 2.0 SunWindows by Philippe Lacroute */
  166. X
  167. X/* must be loaded -lsuntool -lsunwindow -lpixrect */
  168. X
  169. X#include <suntool/tool_hs.h>
  170. X#include <fcntl.h>
  171. X#include <signal.h>
  172. X
  173. X/* Window system variables and functions */
  174. X
  175. X#define CLR    PIX_CLR
  176. X#define SET    PIX_SET
  177. X#define INVERT    PIX_SRC ^ PIX_DST
  178. X#define SPLIT_TEXT_SIZE    5    /* default # lines of text in split mode */
  179. X#define BORDER    5        /* width of the window borders */
  180. X#define SCREEN_DEPTH    1
  181. X#define FIX_PICTURE    1
  182. X#define FIX_SIZE    2
  183. X
  184. X#define ltos_xcor(c)    c + scalex    /* conversion: logo to window */
  185. X#define ltos_ycor(c)    scaley - c    /*         system coordinates */
  186. X
  187. Xstatic short logocur_data[16] = {
  188. X    0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0000, 0x0000, 0xF83E,
  189. X    0x0000, 0x0000, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0000
  190. X};
  191. X
  192. Xmpr_static(logocur_pr, 16, 16, 1, logocur_data);
  193. X
  194. Xstruct cursor logocur = { 7, 7, PIX_SRC ^ PIX_DST, &logocur_pr };
  195. X
  196. Xstatic setwinchflag();
  197. Xextern char pr_reversesrc[];
  198. Xint screen_height, screen_width;/* size for retained pixrect */
  199. Xint gfx_windowfd = -1;        /* window device (blanket) */
  200. Xint real_gfx_fd;        /* gfx window parent */
  201. Xstruct pixwin *gfx_pixwin;    /* actual window */
  202. Xint gfx_flags = 0;        /* used for SIGWINCH */
  203. Xint parentfd;            /* toll window */
  204. Xint textfd;            /* text window */
  205. Xint scalex, scaley;
  206. Xint font_height;
  207. Xint tlines = SPLIT_TEXT_SIZE;
  208. Xstruct rect tool_rect;
  209. Xint sigwinch_ok = 0;
  210. Xint mouse_x = -1, mouse_y = -1;    /* current location of mouse (screen coor.) */
  211. Xint mousein = 0;
  212. X
  213. Xint sunpens[] = {SET, CLR, INVERT};
  214. Xchar state;        /* What state we are in (text, split, full) */
  215. XNUMBER sunoldx,sunoldy;
  216. X
  217. Xint sunturt(),sunfrom(),sunto(),suninit(),sunstate();
  218. X
  219. Xstruct display sun = {
  220. X    0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 1,    /* dims initialized later */
  221. X    "", "", "", "", sunturt, sunfrom, sunto, nullfn, suninit, nullfn,
  222. X    nullfn, nullfn, nullfn, sunstate
  223. X};
  224. X
  225. X#define transline(op,fx,fy,tx,ty)    pw_vector(gfx_pixwin, ltos_xcor(fx), ltos_ycor(fy), ltos_xcor(tx), ltos_ycor(ty), op, 1)
  226. X
  227. Xsunturt(hide)
  228. Xint hide;    /* 1 to erase */
  229. X{
  230. X    NUMBER newx, newy, oldx, oldy, angle;
  231. X    static double scrunch = 1.0;
  232. X
  233. X    if (!hide)
  234. X        scrunch = yscrunch;
  235. X    angle = (mydpy->turth-90.0)*3.141592654/180.0;
  236. X    oldx = mydpy->turtx + 15.0*sin(angle);
  237. X    oldy = mydpy->turty + 15.0*cos(angle);
  238. X    angle = mydpy->turth*3.141592654/180.0;
  239. X    newx = mydpy->turtx + 15.0*sin(angle);
  240. X    newy = mydpy->turty + 15.0*cos(angle);
  241. X    transline(INVERT,(int)oldx,(int)(scrunch*oldy),
  242. X        (int)newx,(int)(scrunch*newy));
  243. X    oldx = newx;
  244. X    oldy = newy;
  245. X    angle = (mydpy->turth+90.0)*3.141592654/180.0;
  246. X    newx = mydpy->turtx + 15.0*sin(angle);
  247. X    newy = mydpy->turty + 15.0*cos(angle);
  248. X    transline(INVERT,(int)oldx,(int)(scrunch*oldy),
  249. X        (int)newx,(int)(scrunch*newy));
  250. X    oldx = newx;
  251. X    oldy = newy;
  252. X    angle = (mydpy->turth-90.0)*3.141592654/180.0;
  253. X    newx = mydpy->turtx + 15.0*sin(angle);
  254. X    newy = mydpy->turty + 15.0*cos(angle);
  255. X    transline(INVERT,(int)oldx,(int)(scrunch*oldy),
  256. X        (int)newx,(int)(scrunch*newy));
  257. X    scrunch = yscrunch;
  258. X}
  259. X
  260. Xsuninit()
  261. X{
  262. X    if (gfx_windowfd < 0) {
  263. X        char *parent, *text, *gfx;
  264. X        struct pixfont *pf = pf_default();
  265. X        struct inputmask im;
  266. X        struct screen scr;
  267. X        int sig_mask;
  268. X
  269. X        sig_mask = sigblock(1 << (SIGWINCH-1));
  270. X
  271. X        /* Get window numbers from environment */
  272. X
  273. X        if ((parent = getenv("LOGO_TOOL")) == NULL) {
  274. X            printf("No LOGO_TOOL environment variable\n");
  275. X            printf("Are you running logo instead of logotool?\n");
  276. X            errhand();
  277. X        }
  278. X        if ((text = getenv("LOGO_TEXT")) == NULL) {
  279. X            printf("No LOGO_TEXT environment variable\n");
  280. X            printf("Are you running logo instead of logotool?\n");
  281. X            errhand();
  282. X        }
  283. X        if ((gfx = getenv("LOGO_GFX")) == NULL) {
  284. X            printf("No LOGO_GFX environment variable\n");
  285. X            printf("Are you running logo instead of logotool?\n");
  286. X            errhand();
  287. X        }
  288. X
  289. X        /* Open windows */
  290. X
  291. X        if ((parentfd = open(parent, 0)) < 0) {
  292. X            printf("Couldn't open parent window %s\n", parent);
  293. X            printf("Sorry, cannot use the turtle!\n");
  294. X            errhand();
  295. X        }
  296. X        if ((textfd = open(text, 0)) < 0) {
  297. X            printf("Couldn't open ttysubwindow %s\n", text);
  298. X            printf("Sorry, cannot use the turtle!\n");
  299. X            errhand();
  300. X        }
  301. X        if ((real_gfx_fd = open(gfx, 0)) < 0) {
  302. X            printf("Couldn't open takeover window %s\n", gfx);
  303. X            printf("Sorry, cannot use the turtle!\n");
  304. X            errhand();
  305. X        }
  306. X
  307. X        /* Find out how big we are */
  308. X
  309. X        win_getrect(parentfd, &tool_rect);
  310. X
  311. X        /* Create window */
  312. X
  313. X        if ((gfx_windowfd = win_getnewwindow()) < 0) {
  314. X            printf("Couldn't get a new window\n");
  315. X            printf("Sorry, cannot use the turtle!\n");
  316. X            errhand();
  317. X        }
  318. X        if (win_insertblanket(gfx_windowfd, real_gfx_fd) != 0) {
  319. X            printf("Blanket window failed\n");
  320. X            printf("Sorry, cannot use the turtle!\n");
  321. X            errhand();
  322. X        }
  323. X        gfx_pixwin = pw_open(gfx_windowfd);
  324. X
  325. X        /*
  326. X         *  send input typed into gfxwindow to ttysubwindow;
  327. X         *  save mouse movement and buttons for gfxsw;
  328. X         *  want non-blocking read for gfxsw
  329. X         */
  330. X
  331. X        input_imnull(&im);
  332. X        win_setinputcodebit(&im, LOC_MOVE);
  333. X        win_setinputcodebit(&im, MS_LEFT);
  334. X        win_setinputcodebit(&im, MS_MIDDLE);
  335. X        win_setinputcodebit(&im, LOC_WINEXIT);
  336. X        win_setinputmask(gfx_windowfd, &im, NULL, win_fdtonumber(textfd));
  337. X        if (fcntl(gfx_windowfd, F_SETFL, FNDELAY) == -1) {
  338. X            printf("Fcntl failed.\n");
  339. X            printf("Please don't use the mouse!\n");
  340. X        }
  341. X        win_setcursor(gfx_windowfd, &logocur);
  342. X
  343. X        /* Create retained pixrect and set SIGWINCH catcher */
  344. X
  345. X        win_screenget(gfx_windowfd, &scr);    /* get screen dims */
  346. X        screen_height = scr.scr_rect.r_height;
  347. X        screen_width = scr.scr_rect.r_width;
  348. X        gfx_pixwin->pw_prretained = 
  349. X            mem_create(screen_height, screen_width, SCREEN_DEPTH);
  350. X        font_height = pf->pf_defaultsize.y;  /* Get the font height */
  351. X        signal(SIGWINCH, setwinchflag);
  352. X        sigsetmask(sig_mask);
  353. X
  354. X        /* Initialize screen size  and display */
  355. X
  356. X        yscrunch = 1.0;
  357. X        gfx_setsize(0);
  358. X    } else
  359. X        sunstate('s');        /* Just redisplay */
  360. X}
  361. X
  362. Xsunfrom(x,y)
  363. XNUMBER x,y;
  364. X{
  365. X    sunoldx = x;
  366. X    sunoldy = y;
  367. X}
  368. X
  369. Xsunto(x,y)
  370. XNUMBER x,y;
  371. X{
  372. X    transline(sunpens[penerase], (int)sunoldx,(int)sunoldy,(int)x,(int)y);
  373. X}
  374. X
  375. Xsunstate(which)
  376. X{
  377. X    struct rect r;
  378. X
  379. X    win_getrect(parentfd, &r);    /* get size of parent */
  380. X    fix_rect(&r);
  381. X    switch (which) {
  382. X    case 's':        /* Split screen - leave lines for text */
  383. X            if (tlines > 0) {
  384. X                if (tlines * font_height <= r.r_height) {
  385. X                    r.r_top += r.r_height - (tlines*font_height);
  386. X                    r.r_height = tlines * font_height;
  387. X                }
  388. X                win_setrect(textfd, &r);
  389. X                putchar('\n');
  390. X                state = 's';
  391. X                break;
  392. X            } /* else fallthrough */
  393. X    case 'f':        /* Full screen - size of parent */
  394. X                /* must get rid of text window */
  395. X            r.r_left = r.r_top = -2000;
  396. X            win_setrect(textfd, &r);
  397. X            putchar('\n');
  398. X            state = which; /* could be either s or f */
  399. X            break;
  400. X    case 't':        /* Text - move graphics window off screen */
  401. X            win_setrect(textfd, &r);
  402. X            state = 't';
  403. X            break;
  404. X    case 'c':
  405. X    case 'w':        /* Clear screen */
  406. X            win_getrect(gfx_windowfd, &r);
  407. X            pw_write(gfx_pixwin, 0, 0,
  408. X                r.r_width, r.r_height,
  409. X                PIX_CLR, NULL, 0, 0);
  410. X            pr_rop(gfx_pixwin->pw_prretained,
  411. X                0, 0, screen_width, screen_height,
  412. X                PIX_CLR, NULL, 0, 0);
  413. X            break;
  414. X    }
  415. X}
  416. X
  417. Xcheckwindow()
  418. X{
  419. X    if (gfx_windowfd < 0)
  420. X        return;
  421. X    if (gfx_flags & FIX_PICTURE) {
  422. X        repaint();
  423. X    }
  424. X    if (gfx_flags & FIX_SIZE) {
  425. X        gfx_setsize(1);
  426. X        repaint();
  427. X    }
  428. X    gfx_flags = 0;
  429. X}
  430. X
  431. Xgfx_setsize(redraw)
  432. Xint redraw;
  433. X{
  434. X    int newx, newy;
  435. X    struct rect r, p;
  436. X
  437. X    win_getrect(parentfd, &r);
  438. X    p = r;
  439. X    fix_rect(&r);
  440. X    win_setrect(real_gfx_fd, &r);
  441. X
  442. X    if (redraw) {
  443. X        sunstate(state);
  444. X        if (p.r_width != tool_rect.r_width)
  445. X            mydpy->xhigh += p.r_width - tool_rect.r_width;
  446. X        if (p.r_height != tool_rect.r_height)
  447. X            mydpy->ylow -= p.r_height - tool_rect.r_height;
  448. X
  449. X        /* Move turtle inside window if it isn't */
  450. X
  451. X        newx = mydpy->turtx;
  452. X        newy = mydpy->turty;
  453. X        if (mydpy->turtx > mydpy->xhigh)
  454. X            newx = mydpy->xhigh;
  455. X        if (mydpy->turtx < mydpy->xlow)
  456. X            newx = mydpy->xlow;
  457. X        if (mydpy->turty > mydpy->yhigh)
  458. X            newy = mydpy->yhigh;
  459. X        if (mydpy->turty < mydpy->ylow)
  460. X            newy = mydpy->ylow;
  461. X        if (newx != mydpy->turtx || newy != mydpy->turty) {
  462. X            if (shown)
  463. X                sunturt(1);
  464. X            mydpy->turtx = newx;
  465. X            mydpy->turty = newy;
  466. X            if (shown)
  467. X                sunturt(0);
  468. X        }
  469. X        tool_rect = p;
  470. X    } else {
  471. X        scalex = r.r_width / 2 - 1;
  472. X        scaley = r.r_height - r.r_height / 2 + 1;
  473. X        mydpy->xhigh = r.r_width / 2;
  474. X        mydpy->xlow = -(mydpy->xhigh) + 1;
  475. X        mydpy->yhigh = r.r_height / 2 + 3;
  476. X        mydpy->ylow = -(mydpy->yhigh) + 4;
  477. X        sunstate('s');
  478. X    }
  479. X}
  480. X
  481. Xstatic
  482. Xsetwinchflag()
  483. X{
  484. X    struct rect r;
  485. X
  486. X    win_getrect(parentfd, &r);
  487. X    if (!rect_equal(&r, &tool_rect))
  488. X        gfx_flags |= FIX_SIZE;
  489. X    gfx_flags |= FIX_PICTURE;
  490. X    if (sigwinch_ok)
  491. X        checkwindow();
  492. X
  493. X}
  494. X
  495. Xrepaint()
  496. X{
  497. X    struct rect r;
  498. X
  499. X    win_getrect(gfx_windowfd, &r);
  500. X    pw_damaged(gfx_pixwin);
  501. X    pw_write(gfx_pixwin, 0, 0, r.r_width, r.r_height,
  502. X        PIX_SRC, gfx_pixwin->pw_prretained, 0, 0);
  503. X    pw_donedamaged(gfx_pixwin);
  504. X}
  505. X
  506. Xstruct object *
  507. Xfill_region()
  508. X{
  509. X    int x = ltos_xcor((int)mydpy->turtx), y = ltos_ycor((int)mydpy->turty);
  510. X    struct rect r;
  511. X
  512. X    tcheck();
  513. X    if (shown)
  514. X        sunturt(1);
  515. X    win_getrect(gfx_windowfd, &r);
  516. X    fill(x, y, r.r_width, r.r_height);
  517. X    if (shown)
  518. X         sunturt(0);
  519. X    return((struct object *) 0);
  520. X}
  521. X
  522. X#define getpixel    ((*(mpr_d(buf)->md_image+(x>>4))>>(15-(x&15)))&1)
  523. X#define getline        pw_read(buf, 0, 0, gfx_width, 1, PIX_SRC, gfx_pixwin, 0, y); yinbuf = y
  524. X#define putline        pw_vector(gfx_pixwin, leftend, y, rightend, y, PIX_SRC, NEWVALUE)
  525. X#define didabove    (y == oldy+1 && leftend >= oldleft && rightend <= oldright)
  526. X#define didbelow    (y == oldy-1 && leftend >= oldleft && rightend <= oldright)
  527. X#define savex        savedx = x
  528. X#define restorex    x = savedx
  529. X#define push        stack[stackptr++] = x | (y << 16)
  530. X#define pop        x = stack[--stackptr] & 65535; y = stack[stackptr] >> 16
  531. X#define stacknotempty    (stackptr > 0)
  532. X#define OLDVALUE    0
  533. X#define NEWVALUE    1
  534. X#define scanline                            \
  535. X        savex;                            \
  536. X        x = leftend;                        \
  537. X        while (x <= rightend) {                    \
  538. X            while(x <= rightend && getpixel != OLDVALUE)    \
  539. X                x++;                    \
  540. X            if (x > rightend)                \
  541. X                break;                    \
  542. X            push;                        \
  543. X            while (x <= rightend && getpixel == OLDVALUE)    \
  544. X                x++;                    \
  545. X        }                            \
  546. X        restorex
  547. X
  548. Xfill(startx, starty, gfx_width, gfx_height)
  549. Xint startx, starty, gfx_width, gfx_height;
  550. X{
  551. X    register int x, y, stackptr = 0, savedx;
  552. X    int oldy, leftend, rightend, oldleft, oldright, yinbuf = -1;
  553. X    long stack[1000];
  554. X    struct pixrect *buf;
  555. X
  556. X    x = startx;
  557. X    y = starty;
  558. X    if (pw_get(gfx_pixwin, x, y) == NEWVALUE)    /* in case the pen */
  559. X        pw_put(gfx_pixwin, x, y, OLDVALUE);    /* is down and this */
  560. X    buf = mem_create(gfx_width, 1, 1);        /* point is written */
  561. X    oldy = y;
  562. X    push;
  563. X    while (stacknotempty) {
  564. X        pop;
  565. X        if (y != yinbuf)
  566. X            getline;
  567. X        if (getpixel == NEWVALUE)
  568. X            continue;
  569. X        savex;
  570. X        x--;
  571. X        while (x >= 0 && getpixel == OLDVALUE)
  572. X            x--;
  573. X        leftend = x + 1;
  574. X        restorex;
  575. X        savex;
  576. X        while (x < gfx_width && getpixel == OLDVALUE)
  577. X            x++;
  578. X        rightend = x - 1;
  579. X        restorex;
  580. X        putline;
  581. X        if (!didabove && y > 0) {
  582. X            y--;
  583. X            getline;
  584. X            scanline;
  585. X            y++;
  586. X        }
  587. X        if (!didbelow && y < gfx_height-1) {
  588. X            y++;
  589. X            getline;
  590. X            scanline;
  591. X            y--;
  592. X        }
  593. X        oldy = y;
  594. X        oldleft = leftend;
  595. X        oldright = rightend;
  596. X    }
  597. X    pr_destroy(buf);
  598. X}
  599. X
  600. Xstruct object *
  601. Xtext_size(arg)
  602. Xregister struct object *arg;
  603. X{
  604. X    int lines;
  605. X    NUMBER ncheck();
  606. X
  607. X    lines = (int)ncheck(arg);
  608. X    if (lines < 0) {
  609. X        printf("textsize takes a positive input\n");
  610. X        errhand();
  611. X    } else {
  612. X        tlines = lines;
  613. X    }
  614. X    if (state == 's')
  615. X        sunstate('s');
  616. X}
  617. X
  618. Xfix_rect(r)
  619. Xstruct rect *r;
  620. X{
  621. X    r->r_width -= 2 * BORDER;
  622. X    r->r_height -= font_height + 1 + BORDER;
  623. X    r->r_top = font_height + 1;
  624. X    r->r_left = BORDER;
  625. X}
  626. X
  627. Xsigwinch_on()
  628. X{
  629. X    checkwindow();
  630. X    sigwinch_ok = 1;
  631. X}
  632. X
  633. Xsigwinch_off()
  634. X{
  635. X    sigwinch_ok = 0;
  636. X}
  637. X
  638. END_OF_sun.i
  639. if test 11542 -ne `wc -c <sun.i`; then
  640.     echo shar: \"sun.i\" unpacked with wrong size!
  641. fi
  642. # end of overwriting check
  643. fi
  644. if test -f logo.c -a "${1}" != "-c" ; then 
  645.   echo shar: Will not over-write existing file \"logo.c\"
  646. else
  647. echo shar: Extracting \"logo.c\" \(3627 characters\)
  648. sed "s/^X//" >logo.c <<'END_OF_logo.c'
  649. X
  650. X/* Parent process which sets up windows and calls logo itself
  651. X * Ttysw insists on forking, so we need two processes
  652. X * Written by Philippe Lacroute at Sun Microsystems Inc. 1983
  653. X */
  654. X
  655. X/*
  656. X * Modified April 1985 for Sun release 2.0 software (PGL)
  657. X */
  658. X
  659. X#include <stdio.h>
  660. X#include <suntool/tool_hs.h>
  661. X#include <suntool/ttysw.h>
  662. X#include <suntool/emptysw.h>
  663. X
  664. X#define LOGOBIN        "logo"
  665. X
  666. Xstruct tool    *tool;
  667. Xstruct toolsw    *ttysw,        /* tty subwindow */
  668. X        *gfxsw;        /* to be overlaid with blanket */
  669. X
  670. Xstatic short icon_data[256] = {
  671. X#include "logo.icon"
  672. X};
  673. X
  674. Xmpr_static(turtle_pr, 64, 64, 1, icon_data);    /* icon */
  675. Xstatic struct icon    turtle_icon  =  {
  676. X    TOOL_ICONWIDTH, TOOL_ICONHEIGHT, NULL,
  677. X    {0, 0, TOOL_ICONWIDTH, TOOL_ICONHEIGHT},
  678. X    &turtle_pr, {0, 0, 0, 0}, NULL, NULL, 0
  679. X};
  680. Xstatic int        sigwinchcatcher(),
  681. X            sigchldcatcher(),
  682. X            mytoolsigwinchhandler(),
  683. X            (*toolsigwinchhandlercached)();
  684. Xchar            tool_name[] = "Sun Logo 2.0",
  685. X            name[WIN_NAMESIZE];
  686. Xint pidchld = -1, killchild();
  687. X
  688. Xmain(argc, argv)
  689. Xint argc;
  690. Xchar *argv[];
  691. X{
  692. X    char **tool_attrs = NULL;
  693. X    struct rect winsize;
  694. X    char *newargv[512];
  695. X    int c;
  696. X
  697. X    if (tool_parse_all(&argc, argv, &tool_attrs, tool_name) == -1) {
  698. X        tool_usage(tool_name);
  699. X        exit(1);
  700. X    }
  701. X    tool = tool_make(WIN_NAME_STRIPE, 1,
  702. X            WIN_LABEL, tool_name,
  703. X            WIN_ICON, &turtle_icon, 0);
  704. X    if (tool == NULL) {
  705. X        fprintf(stderr, "Couldn't create tool.\n");
  706. X        fprintf(stderr, "Are you running suntools?\n");
  707. X        exit(1);
  708. X    }
  709. X    tool_free_attribute_list(tool_attrs);
  710. X
  711. X    toolsigwinchhandlercached = tool->tl_io.tio_handlesigwinch;
  712. X    tool->tl_io.tio_handlesigwinch = mytoolsigwinchhandler;
  713. X    win_getrect(tool->tl_windowfd, &winsize);
  714. X
  715. X    ttysw = ttysw_createtoolsubwindow(tool, "ttysw",
  716. X        winsize.r_width - 2 * tool_borderwidth(tool),
  717. X        winsize.r_height - tool_borderwidth(tool) - tool_stripeheight(tool));
  718. X    gfxsw = esw_createtoolsubwindow(tool, "gfxsw",
  719. X        winsize.r_width - 2 * tool_borderwidth(tool),
  720. X        winsize.r_height - tool_borderwidth(tool) - tool_stripeheight(tool));
  721. X
  722. X    /* Gfxsw must be on the bottom of tree */
  723. X
  724. X    win_remove(gfxsw->ts_windowfd);
  725. X    win_setlink(gfxsw->ts_windowfd, WL_YOUNGERSIB, win_fdtonumber(ttysw->ts_windowfd));
  726. X    win_setlink(gfxsw->ts_windowfd, WL_OLDERSIB, WIN_NULLLINK);
  727. X    win_insert(gfxsw->ts_windowfd);
  728. X
  729. X    /* set environmanet vars */
  730. X
  731. X    win_fdtoname(tool->tl_windowfd, name);
  732. X    setenv("LOGO_TOOL", name);
  733. X    win_fdtoname(ttysw->ts_windowfd, name);
  734. X    setenv("LOGO_TEXT", name);
  735. X    win_fdtoname(gfxsw->ts_windowfd, name);
  736. X    setenv("LOGO_GFX", name);
  737. X
  738. X    /* set signals */
  739. X
  740. X    signal(SIGWINCH, sigwinchcatcher);
  741. X    signal(SIGCHLD, sigchldcatcher);
  742. X    signal(SIGINT, SIG_IGN);
  743. X    signal(SIGQUIT, SIG_IGN);
  744. X
  745. X    newargv[0] = LOGOBIN;
  746. X    for (c = 1; c < argc; c++)
  747. X        newargv[c] = argv[c];
  748. X    argv[c] = 0;
  749. X
  750. X    /* install everything */
  751. X
  752. X    tool_install(tool);
  753. X    if ((pidchld = ttysw_fork(ttysw->ts_data, newargv, &ttysw->ts_io.tio_inputmask,
  754. X        &ttysw->ts_io.tio_outputmask, &ttysw->ts_io.tio_exceptmask)) == -1) {
  755. X            perror("logotool");
  756. X        exit(1);
  757. X    }
  758. X
  759. X    /* run the ttysw */
  760. X
  761. X    tool_select(tool, 1);    /* 1 child to wait for */
  762. X
  763. X    /* clean up */
  764. X
  765. X    tool_destroy(tool);
  766. X    exit(0);
  767. X}
  768. X
  769. Xstatic
  770. Xsigchldcatcher()
  771. X{
  772. X    tool_sigchld(tool);
  773. X}
  774. X
  775. Xstatic
  776. Xsigwinchcatcher()
  777. X{
  778. X    tool_sigwinch(tool);
  779. X    if (pidchld != -1)
  780. X        kill(pidchld, SIGWINCH);
  781. X}
  782. X
  783. Xnullfunc()
  784. X{
  785. X}
  786. X
  787. X/*
  788. X   toolsigwinchhandlercached will rearrange windows when it
  789. X   detects that its size has changed.  The following procedure
  790. X   fools toolsigwinchhandlercached into thinking that there
  791. X   has been no change. 
  792. X */
  793. X
  794. Xstatic int
  795. Xmytoolsigwinchhandler(tool)
  796. X    struct  tool *tool;
  797. X{
  798. X    struct  rect rect;
  799. X
  800. X    win_getsize(tool->tl_windowfd, &rect);
  801. X    tool->tl_rectcache = rect;
  802. X    toolsigwinchhandlercached(tool);
  803. X}
  804. X
  805. END_OF_logo.c
  806. if test 3627 -ne `wc -c <logo.c`; then
  807.     echo shar: \"logo.c\" unpacked with wrong size!
  808. fi
  809. # end of overwriting check
  810. fi
  811. if test -f logo.icon -a "${1}" != "-c" ; then 
  812.   echo shar: Will not over-write existing file \"logo.icon\"
  813. else
  814. echo shar: Extracting \"logo.icon\" \(2212 characters\)
  815. sed "s/^X//" >logo.icon <<'END_OF_logo.icon'
  816. X
  817. X/* Format_version=1, Width=64, Height=64, Depth=1, Valid_bits_per_item=16
  818. X * Description: A turtle.
  819. X * Background: Root gray.
  820. X */
  821. X    0x8888, 0x8888, 0x8888, 0x8888, 0x8888, 0x8888, 0x8888, 0x8888,
  822. X    0x2222, 0x2222, 0x2222, 0x2222, 0x2222, 0x2222, 0x2222, 0x2222,
  823. X    0x8888, 0x888B, 0xC888, 0x8888, 0x8888, 0x888F, 0xE888, 0x8888,
  824. X    0x2222, 0x222F, 0xF222, 0x2222, 0x2222, 0x222F, 0xF222, 0x2222,
  825. X    0x8888, 0x889F, 0xF888, 0x8888, 0x8888, 0x889F, 0xF888, 0x8888,
  826. X    0x2222, 0x223F, 0xFA22, 0x2222, 0x2222, 0x223F, 0xFA22, 0x2222,
  827. X    0x8888, 0x888F, 0xF888, 0x8888, 0x8888, 0x888F, 0xF088, 0x8888,
  828. X    0x2222, 0x2223, 0xE222, 0x2222, 0x2222, 0x2223, 0xE23A, 0x2222,
  829. X    0x8888, 0xF88B, 0xC8FC, 0x8888, 0x8889, 0xFC9F, 0xF8FE, 0x8888,
  830. X    0x2221, 0xFE3F, 0xFFFE, 0x2222, 0x2221, 0xFFDF, 0xFBFE, 0x2222,
  831. X    0x8889, 0xFFDF, 0xF3FC, 0x8888, 0x8888, 0xFFDF, 0xF7F8, 0x8888,
  832. X    0x2222, 0x7FDF, 0xF7F2, 0x2222, 0x2222, 0x3FDF, 0xE7E2, 0x2222,
  833. X    0x8888, 0x8FEF, 0x9FC8, 0x8888, 0x8888, 0x8BF0, 0x7FC8, 0x8888,
  834. X    0x2222, 0x27FF, 0xFFE2, 0x2222, 0x2222, 0x24FF, 0xFFA2, 0x2222,
  835. X    0x8888, 0x8EFF, 0xFE28, 0x8888, 0x8888, 0x8F78, 0x7EE8, 0x8888,
  836. X    0x2222, 0x27BB, 0xBDE2, 0x2222, 0x2222, 0x27BB, 0xB9E2, 0x2222,
  837. X    0x8888, 0x8FDB, 0xBBE8, 0x8888, 0x8888, 0x8FD9, 0xBBE8, 0x8888,
  838. X    0x2222, 0x273E, 0x3BE2, 0x2222, 0x2222, 0x277F, 0xFBE2, 0x2222,
  839. X    0x8888, 0x8EFF, 0xFBE8, 0x8888, 0x8888, 0x8CFC, 0x79E8, 0x8888,
  840. X    0x2222, 0x23FD, 0x7E22, 0x2222, 0x2222, 0x23FB, 0xBF22, 0x2222,
  841. X    0x8888, 0x8BF3, 0xDFE8, 0x8888, 0x8888, 0x8FE7, 0xDFF8, 0x8888,
  842. X    0x2222, 0x3FEF, 0xCFFA, 0x2222, 0x2222, 0x7FCF, 0xEFFE, 0x2222,
  843. X    0x8888, 0xFFDF, 0xEFFE, 0x8888, 0x8888, 0xFFBF, 0xF8FE, 0x8888,
  844. X    0x2222, 0xFE2F, 0xE23E, 0x2222, 0x2222, 0xFC2F, 0xE23E, 0x2222,
  845. X    0x8888, 0xF88F, 0xE88C, 0x8888, 0x8888, 0x888F, 0xE888, 0x8888,
  846. X    0x2222, 0x222F, 0xE222, 0x2222, 0x2222, 0x222F, 0xE222, 0x2222,
  847. X    0x8888, 0x8887, 0xC888, 0x8888, 0x8888, 0x888B, 0x8888, 0x8888,
  848. X    0x2222, 0x2222, 0x2222, 0x2222, 0x2222, 0x2222, 0x2222, 0x2222,
  849. X    0x8888, 0x8888, 0x8888, 0x8888, 0x8888, 0x8888, 0x8888, 0x8888,
  850. X    0x2222, 0x2222, 0x2222, 0x2222, 0x2222, 0x2222, 0x2222, 0x2222,
  851. X    0x8888, 0x8888, 0x8888, 0x8888, 0x8888, 0x8888, 0x8888, 0x8888,
  852. X    0x2222, 0x2222, 0x2222, 0x2222, 0x2222, 0x2222, 0x2222, 0x2222
  853. X
  854. X
  855. END_OF_logo.icon
  856. if test 2212 -ne `wc -c <logo.icon`; then
  857.     echo shar: \"logo.icon\" unpacked with wrong size!
  858. fi
  859. # end of overwriting check
  860. fi
  861. if test -f Make.Sun -a "${1}" != "-c" ; then 
  862.   echo shar: Will not over-write existing file \"Make.Sun\"
  863. else
  864. echo shar: Extracting \"Make.Sun\" \(1031 characters\)
  865. sed "s/^X//" >Make.Sun <<'END_OF_Make.Sun'
  866. X
  867. X# Makefile modified for use on Suns
  868. X
  869. XCFLAGS = -O -Usun
  870. XLIBS = -lsuntool -lsunwindow -lpixrect -lm -ltermlib -lc
  871. X#LDFLAGS = -X -i
  872. XLDFLAGS = -X
  873. X
  874. Xall:    logo logotool logohead
  875. X
  876. Xlogo:    y.tab.o logoparse.o zerr.o main.o logoop.o logoaux.o unix.o \
  877. X    storage.o turtle.o procedit.o logonum.o procvars.o logoproc.o \
  878. X    proplist.o
  879. X    ld $(LDFLAGS) -o logo /lib/crt0.o *.o $(LIBS)
  880. X
  881. Xlogotool:    logo.c logo.icon
  882. X    cc -o logotool $(CFLAGS) logo.c -lsuntool -lsunwindow -lpixrect
  883. X
  884. Xlogo.c:
  885. X    
  886. X
  887. Xturtle.o:    atari.i gigi.i adm.i tek.i admtek.i sun.i
  888. X
  889. Xy.tab.c:    logo.y
  890. X    yacc logo.y
  891. X
  892. Xlogohead:    logohead.c
  893. X    cc -O -o logohead logohead.c
  894. X
  895. Xhelp:    splithelp logoman
  896. X    ./makehelp
  897. X
  898. Xsplithelp:    splithelp.c
  899. X    cc -O -o splithelp splithelp.c
  900. X
  901. Xinstall:
  902. X    cp logo /usr/local/logo
  903. X    cp logotool /usr/local/logotool
  904. X    -mkdir /usr/local/lib/logo
  905. X    -mkdir /usr/local/lib/logo/doc
  906. X    cp help/* /usr/local/lib/logo/doc
  907. X    cp helpfile applediff olddiff /usr/local/lib/logo/doc
  908. X    cp library/* /usr/local/lib/logo
  909. X    cp logohead /usr/local/lib/logo
  910. X
  911. Xclean:
  912. X    rm *.o logo logotool logohead splithelp
  913. END_OF_Make.Sun
  914. if test 1031 -ne `wc -c <Make.Sun`; then
  915.     echo shar: \"Make.Sun\" unpacked with wrong size!
  916. fi
  917. # end of overwriting check
  918. fi
  919. echo shar: End of shell archive.
  920. exit 0
  921. -- 
  922.  
  923. Rich $alz            "Anger is an energy"
  924. Cronus Project, BBN Labs    rsalz@pineapple.bbn.com
  925. Moderator, comp.sources.unix    sources@uunet.uu.net
  926.